<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
  <meta name="generator" content=
  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org">

  <title>find_first_of</title>
  <link href="../cppreference.css" rel="stylesheet" type="text/css">
</head>

<body>
<table>
  <tr>
  <td>
  <div class="body-content">

  <div class="header-box">
    <a href="../index.html">cppreference.com</a> &gt; <a href=
    "index.html">C++ Algorithms</a> &gt; <a href=
    "find_first_of.html">find_first_of</a>
  </div>

  <div class="name-format">
    find_first_of
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;algorithm&gt;
  iterator find_first_of( iterator start, iterator end, iterator find_start, iterator find_end );
  iterator find_first_of( iterator start, iterator end, iterator find_start, iterator find_end, BinPred bp );
</pre>

  <p>The find_first_of() function searches for the first occurence of
  any element between <em>find_start</em> and <em>find_end</em>. The
  data that are searched are those between <em>start</em> and
  <em>end</em>.</p>

  <p>If any element between <em>find_start</em> and <em>find_end</em>
  is found, an iterator pointing to that element is returned.
  Otherwise, an iterator pointing to <em>end</em> is returned.</p>

  <p>For example, the following code searches for a 9, 4, or 7 in an
  array of integers:</p>
  <pre class="example-code">
 int nums[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
 int* result;
 int start = 0;
 int end = 10;          

 int targets[] = { 9, 4, 7 };
 result = find_first_of( nums + start, nums + end, targets + 0, targets + 2 );
 if( *result == nums[end] ) {
   cout &lt;&lt; &quot;Did not find any of { 9, 4, 7 }&quot; &lt;&lt; endl;
 } else {
   cout &lt;&lt; &quot;Found a matching target: &quot; &lt;&lt; *result &lt;&lt; endl;
 }              
</pre>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="adjacent_find.html">adjacent_find</a><br>
    <a href="find.html">find</a><br>
    <a href="find_end.html">find_end</a><br>
    <a href="find_if.html">find_if</a><br>
    (Standard C String and Character) <a href=
    "../stdstring/strpbrk.html">strpbrk</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
